# -*- coding: utf-8 -*-

#
# Copyright (c) 2012-2024 Virtual Cable S.L.U.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
#    * Redistributions of source code must retain the above copyright notice,
#      this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright notice,
#      this list of conditions and the following disclaimer in the documentation
#      and/or other materials provided with the distribution.
#    * Neither the name of Virtual Cable S.L.U. nor the names of its contributors
#      may be used to endorse or promote products derived from this software
#      without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""
Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import base64
import typing

DEFAULT_IMAGE_BASE64: typing.Final[str] = (
    'iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9'
    'kT1Iw0AYht+malUqCnYQcchQnexiRRxLFYtgobQVWnUwufRHaNKQpLg4Cq4FB38Wqw4u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'
    's2W1xQAAAABJRU5ErkJggg=='
)
DEFAULT_IMAGE: typing.Final[bytes] = base64.b64decode(DEFAULT_IMAGE_BASE64)

DEFAULT_THUMB_BASE64: typing.Final[str] = (
'iVBORw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